
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.utils.AddDocumentUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.clients.TopicServiceClient" %>

<%
     String parentPath = request.getParameter("parentPath");
     String resourceName = request.getParameter("documentName");
     
     String sPath="/";
     try {
        AddDocumentUtil.addDocumentBean(request, config, session); //add bean
    //    AddDocumentUtil.applyTags(request, config, session); //add tags

        
        if(!parentPath.equals("/") ){
             sPath = parentPath+"/"+resourceName;
         } else{
            sPath = parentPath+resourceName;
        }
         TopicServiceClient client = new TopicServiceClient(config, session);
         
         String dPath = request.getParameter("diaRelDoc1");
         dPath += "../../../resources/resource.jsp?path="+dPath;

         String type = "Related Doc"; 
         client.addAssociation(sPath,dPath,type);  
    } catch (UIException e) {
            System.out.println("Could not add documentation.");
    } catch (Exception e){
            System.out.println("Exception thrown when adding a new documentation.");
    }
     
    String resourcePagePath = "../../../resources/resource.jsp?path=" + sPath;
    //response.sendRedirect(resourcePagePath);
    
    %>

   
<!--
/*
 *validation of diaRelDoc1
    if (reason == "") {
        typeForm.associationPaths.value = typeForm.associationPaths.value.replace(/^\s\s*
   ds      /, '').replace(/\s\s*$/, '');
        if (typeForm.associationPaths.value == "") {
            reason = org_wso2_carbon_registry_relations_ui_jsi18n["path.cannot.contain.only.white.spaces"];
        }
    }
 *
 */ 
-->